package dnet

import "strings"

type FtpCmdRequest struct {
	Conn     *DNetFtpServConnHandler
	Command  string
	Param    string
	RespCode int
	Resp     string
}

func NewFtpCmdRequest(conn *DNetFtpServConnHandler, cmdline string) *FtpCmdRequest {
	rval := &FtpCmdRequest{
		Conn: conn,
	}
	rval.ParseCmdline(cmdline)
	return rval
}

func (this *FtpCmdRequest) ParseCmdline(cmdline string) {
	this.Command, this.Param = Split2(cmdline, " ")
	this.Command = strings.ToUpper(this.Command)
}

func (this *FtpCmdRequest) GetUser() string {
	return this.Conn.user
}

func (this *FtpCmdRequest) GetPass() string {
	return this.Conn.pass
}

func (this *FtpCmdRequest) ChangePWD(val string) {
	this.Conn.pwd = val
}

func (this *FtpCmdRequest) GetPWD() string {
	return this.Conn.pwd
}

func (this *FtpCmdRequest) Response(code int, msg string) {
	this.Conn.writeMessage(code, msg)
}
